/*
 * @Description: 主路由
 * @Author: Ronda
 * @Date: 2021-07-23 17:32:04
 * @LastEditors: Ronda
 * @LastEditTime: 2023-12-20 16:23:54
 */
import Vue from "vue";
import Router from "vue-router";

Vue.use(Router);

/* Layout */
import Layout from "@/layout";

export const constantRoutes = [
    {
        path: "/redirect",
        component: Layout,
        hidden: true,
        children: [
            {
                path: "/redirect/:path*",
                component: () => import("@/pages/base/redirect/Index")
            }
        ]
    },
    {
        path: "/404",
        component: () => import("@/pages/base/error-page/404"),
        hidden: true
    },
    {
        path: "/401",
        component: () => import("@/pages/base/error-page/401"),
        hidden: true
    },
    {
        path: "/login",
        component: () => import("@/pages/login/index"),
        hidden: true
    },
    {
        path: "/",
        component: Layout,
        redirect: "/dashboard",
        children: [
            {
                path: "/dashboard",
                component: () => import("@/pages/dashboard/Index"),
                name: "dashboard",
                meta: {
                    title: "数据大屏",
                    icon: "icon_20",
                    affix: true
                }
            }
        ]
    },
    
    {
        path: "/shuyuan",
        component: Layout,
        redirect: "/shuyuan/Index",
        children: [
            {
                path: "Index",
                component: () => import("@/pages/shuyuan/Index"),
                name: "shuyuanindex",
                meta: {
                    title: "溯源管理",
                    icon: "icon_1",
                    affix: true
                }
            }
        ]
    },
    {
        path: "/chandi",
        component: Layout,
        redirect: "/chandi/Index",
        children: [
            {
                path: "Index",
                component: () => import("@/pages/pichi/Index"),
                name: "pichiindex",
                meta: {
                    title: "批次管理",
                    icon: "icon_13",
                    affix: true
                }
            },
            {
                path: "changkuIndex",
                component: () => import("@/pages/changku/Index"),
                name: "changkuindex",
                meta: {
                    title: "仓库管理",
                    icon: "icon_14",
                    affix: true
                }
            }
        ],
        meta: {
            title: "产地管理",
            icon: "icon_12",
            affix: true
        }
    },
    {
        path: "/xiaoshou",
        component: Layout,
        redirect: "/dingdan/Index",
        children: [
            {
                path: "Index",
                component: () => import("@/pages/dingdan/Index"),
                name: "dingdanindex",
                meta: {
                    title: "订单管理",
                    icon: "icon_3",
                    affix: true
                }
            },
            {
                path: "shangpingIndex",
                component: () => import("@/pages/shangping/Index"),
                name: "shangpingindex",
                meta: {
                    title: "商品管理",
                    icon: "icon_15",
                    affix: true
                }
            }
        ],
        meta: {
            title: "销售管理",
            icon: "icon_16",
            affix: true
        }
    },
    {
        path: "/shengchan",
        component: Layout,
        redirect: "/shengchan/Index",
        children: [
            {
                path: "Index",
                component: () => import("@/pages/chazhong/Index"),
                name: "chazhongindex",
                meta: {
                    title: "茶种管理",
                    icon: "icon_17",
                    affix: true
                }
            },
             {
                path: "nongzhuoIndex",
                component: () => import("@/pages/nongzhuo/Index"),
                name: "nongzhuoindex",
                meta: {
                    title: "农作梳理",
                    icon: "icon_18",
                    affix: true
                }
            }
        ],
        meta: {
            title: "生产管理",
            icon: "icon_19",
            affix: true
        }
    },
    {
        path: "/chadi",
        component: Layout,
        redirect: "/chayuan/Index",
        children: [
            {
                path: "Index",
                component: () => import("@/pages/chayuan/Index"),
                name: "chayuanindex",
                meta: {
                    title: "茶园管理",
                    icon: "icon_20",
                    affix: true
                }
            }
        ],
        meta: {
            title: "茶地管理",
            icon: "icon_21",
            affix: true
        }
    }
];

const createRouter = () =>
    new Router({
        // mode: 'history', // require service support
        scrollBehavior: () => ({ y: 0 }),
        routes: constantRoutes
    });

const router = createRouter();

export function resetRouter() {
    const newRouter = createRouter();
    router.matcher = newRouter.matcher; // reset router
}

export default router;
